package com.wlyuan.open.scanner.application.handler.incr;

import com.wlyuan.open.OpenBaseSyncDTO;
import com.wlyuan.open.scanner.application.factory.SyncFactory;
import com.wlyuan.open.scanner.service.ScannerService;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author lijing
 * @description
 */
@Slf4j
@Service
public abstract class BaseIncrHandler<T extends OpenBaseSyncDTO> {
    @Autowired
    private SyncFactory syncFactory;
    @Autowired
    private ScannerService scannerService;

    /**
     * 增量同步
     *
     * @param sourceId
     */
    public void increment(Long sourceId) {
        var target = process(sourceId);
        sync(target);
    }

    private void sync(OpenBaseSyncDTO source) {
        //开放平台同步数据
        syncFactory.sync(source);

    }

    /**
     * 同步数据
     *
     * @param sourceId
     * @return
     */
    public abstract T process(Long sourceId);

    /**
     * 根据租户
     *
     * @param tenantId
     */
    public abstract void incrByTenantId(Long tenantId);

    /**
     * 根据时间
     *
     * @param startTime
     * @param endTime
     */
    public abstract void incrByTime(Long tenantId, String startTime, String endTime);

    /**
     * 获取同步类型
     *
     * @return
     */
    public abstract String getSyncType();
}
